Repository navigation
test(SDK-615): inbox message display URL handling - #940
jferrao-itrbl wants to merge 3 commits into
Conversation
Align reserved iterable:// handling so unknown schemes do not reach urlHandler; only delete and dismiss run SDK actions.
|
Coverage Impact ⬆️ Merging this pull request will increase total coverage on Modified Files with Diff Coverage (1)
🛟 Help
|
Drop the file-local jest.mock so we use jest.setup’s View stub; find the WebView node by View type + onMessage.
|
Product note — unknown The behavior where we still call
So the most consistent product answer is: keep click/close tracking for reserved-but-unknown |
Comment why trackInAppClick/Close run before unknown iterable:// handling.
rtlsilva
left a comment
There was a problem hiding this comment.
Requesting changes, plus one additional PR-level comment:
The body says "SDK-633 alignment", but this PR ships only SDK-633 item 3 (inbox parity). Suggest saying that SDK-633 stays open for:
- the example:
example/src/hooks/useIterableApp.tsx:197still setsallowedProtocols = ['app', 'iterable'], and itsurlHandler(lines 178–189) still treats these links as navigation. After this PR, example inbox links that useiterable://stop navigating. - docs saying
iterable://is reserved fordelete/dismiss(SDK-633 AC1). None exist yet. - SDK-633 AC3 and AC5.
| // iterable:// is reserved — only delete/dismiss are SDK actions (SDK-633) | ||
| } else if (URL.startsWith('iterable://')) { | ||
| return; |
There was a problem hiding this comment.
This branch tracks a close but leaves the message open. Lines 169–179 already sent trackInAppClick and trackInAppClose(link), and return then keeps the message on screen. When the user taps Inbox, line 219 sends a second close (back) for the same view.
Native in-apps close the message after every link click, including an unknown iterable://. Only the action is skipped:
- Android 3.10.1
IterableInAppFragmentHTMLNotification.onUrlClicked: click, close(LINK), thenhideWebView(). - iOS 6.7.5
IterableHtmlMessageViewControllerdecidePolicyFor:trackClickOnDismiss, thenanimateWhileLeaving. close(link) is sent on disappear.
So "swallow, same as native" in SDK-633 means: close the message and call no handler.
| // iterable:// is reserved — only delete/dismiss are SDK actions (SDK-633) | |
| } else if (URL.startsWith('iterable://')) { | |
| return; | |
| // iterable:// is reserved: only delete/dismiss are SDK actions (SDK-633). | |
| // Any other path closes the message without calling a handler, like native. | |
| } else if (URL.startsWith('iterable://')) { | |
| returnToInbox(); |
SDK-615 AC4 ("no navigation") should then read "no urlHandler or customActionHandler call".
| // Track before routing: aligns with native HTML in-app (click/close first, | ||
| // then iterable:// handling). Unknown iterable:// paths still get these | ||
| // events while skipping urlHandler / returnToInbox below. |
There was a problem hiding this comment.
This comment says unknown paths skip returnToInbox. Native closes the message (see the comment on line 189).
| // Track before routing: aligns with native HTML in-app (click/close first, | |
| // then iterable:// handling). Unknown iterable:// paths still get these | |
| // events while skipping urlHandler / returnToInbox below. | |
| // Track before routing, like native HTML in-apps: every link click sends | |
| // click and close(link), then the message closes. Unknown iterable:// | |
| // paths close without calling urlHandler or customActionHandler. |
| it('should swallow unknown iterable:// URLs without calling urlHandler or returning to inbox', async () => { | ||
| const utils = await renderWithContent(); | ||
|
|
||
| postWebViewMessage(utils, 'iterable://foo'); | ||
|
|
||
| expect(returnToInbox).not.toHaveBeenCalled(); | ||
| expect(urlHandler).not.toHaveBeenCalled(); | ||
| expect(MockLinking.openURL).not.toHaveBeenCalled(); | ||
| expect(deleteRow).not.toHaveBeenCalled(); | ||
| }); |
There was a problem hiding this comment.
This test locks in the open-message behaviour, and it never checks customActionHandler (SDK-633: "Do not forward unknown iterable:// to customActionHandler"). With the fix proposed in IterableInboxMessageDisplay.tsx's comments:
| it('should swallow unknown iterable:// URLs without calling urlHandler or returning to inbox', async () => { | |
| const utils = await renderWithContent(); | |
| postWebViewMessage(utils, 'iterable://foo'); | |
| expect(returnToInbox).not.toHaveBeenCalled(); | |
| expect(urlHandler).not.toHaveBeenCalled(); | |
| expect(MockLinking.openURL).not.toHaveBeenCalled(); | |
| expect(deleteRow).not.toHaveBeenCalled(); | |
| }); | |
| it('should close the message for unknown iterable:// URLs without calling any handler', async () => { | |
| const utils = await renderWithContent(); | |
| const url = 'iterable://foo'; | |
| postWebViewMessage(utils, url); | |
| expect(returnToInbox).toHaveBeenCalledTimes(1); | |
| expect(trackInAppClickSpy).toHaveBeenCalledTimes(1); | |
| expect(trackInAppCloseSpy).toHaveBeenCalledTimes(1); | |
| expect(trackInAppCloseSpy).toHaveBeenCalledWith( | |
| rowViewModel.inAppMessage, | |
| IterableInAppLocation.inbox, | |
| IterableInAppCloseSource.link, | |
| url | |
| ); | |
| expect(urlHandler).not.toHaveBeenCalled(); | |
| expect(customActionHandler).not.toHaveBeenCalled(); | |
| expect(MockLinking.openURL).not.toHaveBeenCalled(); | |
| expect(deleteRow).not.toHaveBeenCalled(); | |
| }); |
|
|
||
| expect(returnToInbox).toHaveBeenCalled(); | ||
| expect(deleteRow).not.toHaveBeenCalled(); | ||
| expect(urlHandler).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
Suggest adding expect(customActionHandler).not.toHaveBeenCalled(); here, and in the iterable://delete test (after line 151). As it is, a branch that forwarded reserved URLs to customActionHandler would pass all three reserved-URL tests.
|
|
||
| ### Fixes | ||
|
|
||
| - Inbox message HTML links: unknown `iterable://` URLs no longer fall through to `urlHandler`; only `iterable://delete` and `iterable://dismiss` are handled as SDK actions (SDK-615, SDK-633). |
There was a problem hiding this comment.
This changes behaviour for anyone who used iterable://… links as deep links in inbox HTML. The bullet should tell them what to use instead. action://name is already documented on customActionHandler in IterableConfig.ts.
| - Inbox message HTML links: unknown `iterable://` URLs no longer fall through to `urlHandler`; only `iterable://delete` and `iterable://dismiss` are handled as SDK actions (SDK-615, SDK-633). | |
| - Fixed inbox HTML messages forwarding unknown `iterable://` links to `urlHandler`. `iterable://` is reserved for `iterable://delete` and `iterable://dismiss`; any other `iterable://` link now closes the message without calling a handler. Use `action://name` for custom actions (`customActionHandler`) and `https` or your app's own scheme for deep links (`urlHandler`). |
|
|
||
| ### Updates | ||
|
|
||
| - Added unit tests for inbox message link handling in `IterableInboxMessageDisplay` (SDK-615). |
There was a problem hiding this comment.
Same comment as in #937
| - Added unit tests for inbox message link handling in `IterableInboxMessageDisplay` (SDK-615). |

📝 Summary
Adds Jest coverage for
IterableInboxMessageDisplaylink routing and fixes reservediterable://handling so unknown paths are not forwarded tourlHandler.🎟️ Jira Ticket: SDK-615
📖 Description
IterableInboxMessageDisplay.test.tsxexercises WebViewonMessageflows: https,iterable://delete/dismiss,action://, unknowniterable://, custom scheme →urlHandler, andtrackInAppClick/trackInAppClose.IterableInboxMessageDisplayreturns early for any otheriterable://URL after delete/dismiss (SDK-633 alignment).CHANGELOG.mdUnreleased notes.🧪 How to test?
yarn lint && yarn typecheck && yarn test --coverage && yarn check:circular && yarn prepare🧾 Changelog
Unreleased entries in
CHANGELOG.md(customer-facing fix + tests note).🐞 Github Issues solved
N/A